from distutils.core import setup
import shutil as sh
import os

if os.name == "nt":
    import py2exe
    
    setup(console=['bmk.py'])
    #setup(console=['blitzcc.py'])
    #setup(console=['profiler.py'])
    
    dir = "C:/Programme/BlitzMax/bin/"
    #dir = "C:/Programme/Blitz3D/bin/"
    #dir = "C:/Dokumente und Einstellungen/Eduard/Desktop/CODE/Blitz3D/bin/"
    
    sh.rmtree(dir + ".svn", True)
    
    for file in os.listdir("./dist"):
        if file[0] != '.':
            if os.path.isfile("dist/" + file):
                print "Copy '" + file + "'"
                sh.copy("dist/" + file, dir + file)
            else:
                print "CopyDir '" + file + "'"
                try:
                    sh.rmtree(dir + file + "/.svn", True)
                    #sh.rmtree(dir + file, True)
                    pass
                except:
                    print "Error"
                try:
                    sh.copytree("dist/" + file, dir + file)
                except:
                    print "Error"
    
elif os.name == "posix":
    dir = "/home/eduard/Apps/BlitzMax/bin/"
    
    def copy(file, to, cmd):
        cmd(file, dir + to)
    
    copy("dist/config.ini", "config.ini", sh.copy)
    copy("bmk.py", "bmk", sh.copystat)
    copy("App.py", "App.py", sh.copy)
    copy("BMaxPrecompiler.py", "BMaxPrecompiler.py", sh.copy)
    copy("Utils.py", "Utils.py", sh.copy)
    
    sh.rmtree(dir + "scripts", True)
    sh.rmtree(dir + "styles", True)
    
    copy("dist/scripts", "scripts", sh.copytree)
    copy("dist/styles", "styles", sh.copytree)
    
print "Done"
    